module.exports = function(sequelize, DataTypes) {
  var User = sequelize.define('user', {
    uuid: {
      type: DataTypes.UUID,
      defaultValue: DataTypes.UUIDV4,
      primaryKey: true
    },
    name: {type: DataTypes.STRING(20)},
    uname: {type: DataTypes.STRING(20), unique: true},
    pass: {type: DataTypes.STRING(100)},
    status: {
      type: DataTypes.BOOLEAN,
      defaultValue: 1,
      get: function () {
        return this.getDataValue('status') * 1;
      }
    },
    pcode: {type: DataTypes.STRING(20)},
    plevel: {type: DataTypes.STRING(2)},
    event_uuid: {
      type: DataTypes.UUID
    }
  }, {
    // 是否需要增加created_at、updated_at、deleted_at字段
    timestamps: true,
    underscored: true,
    // 设置paranoid为true（此种模式下，删除数据时不会进行物理删除，而是设置deleted_at为当前时间
    paranoid: true
  });

  User.associate = function(models) {
    // Using additional options like CASCADE etc for demonstration
    // Can also simply do Task.belongsTo(models.User);
    // User.belongsTo(models.xxx, {
    //   // onDelete: 'CASCADE',
    // });
    User.belongsTo(models.event, {
      // onDelete: 'CASCADE',
    });
  };

  return User;
};
